﻿
@{
    ViewData["Title"] = "DailyList";
}

@section Scripts
    {
    <link href="~/css/page.css" rel="stylesheet" />
    <script src="~/echats/echarts.js"></script>
    <style>

        .unshow > #result {
            display: none;
        }

        pre {
            padding: 5px;
            margin: 5px;
        }

        .string {
            color: green;
        }

        .number {
            color: darkorange;
        }

        .boolean {
            color: blue;
        }

        .null {
            color: magenta;
        }

        .key {
            color: red;
        }

        blockquote {
            padding: 20px;
            margin: 1em 0;
            background-color: #f7f7f7;
            border-left: 0.25em solid #b4b4b4;
            word-break: break-word;
            font-size: 16px;
            font-weight: 400;
            line-height: 30px;
        }
    </style>
    <script type="text/html" id="barAction">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        // 自定义模块
        layui.config({
            base: '/design/ext/',   // 模块目录
            version: 'v1.3.20'
        }).extend({                         // 模块别名
            soulTable: 'tableChild'
        });

        layui.use(['form', 'table', 'tableChild', 'laydate', 'treeSelect'], function () {
            var table = layui.table,
                form = layui.form,
                tableChild = layui.tableChild,
                treeSelect = layui.treeSelect,
                $ = layui.$;

            var obj = new Date();
            year = obj.getFullYear();

            layui.laydate.render({
                elem: '#vardateTime'
                , type: 'year'
                , value: year
            });

            //地区
            treeSelect.render({
                // 选择器
                elem: '#varProjectName',
                // 数据
                 data: '/MarketPrice/GetAreaTreeAll?name=' + localStorage.getItem("X-AreCode"),
                // 请求头
                //  headers: { 'Authorization': 'Bearer ' + localStorage.getItem("X-TOKEN") },
                // 异步加载方式：get/post，默认get
                type: 'get',
                // 占位符
                placeholder: '地区',
                // 是否开启搜索功能：true/false，默认false
                search: true,
                // 一些可定制的样式
                style: {
                    folder: {
                        enable: true
                    },
                    line: {
                        enable: true
                    }
                },
                // 点击回调
                click: function (d) {
                    console.log(d);
                },
                // 加载完成后的回调函数
                success: function (d) {
                    console.log(d);
                    //                选中节点，根据id筛选
                    treeSelect.checkNode('varProjectName', 3);

                    // console.log($('#varProjectName').val());

                    //                获取zTree对象，可以调用zTree方法
                    var treeObj = treeSelect.zTree('varProjectName');
                    console.log(treeObj);

                    //                刷新树结构
                    treeSelect.refresh('varProjectName');
                }
            });

            //鱼种
            treeSelect.render({
                // 选择器
                elem: '#varFishName',
                // 数据
                data: '/MarketPrice/GetFishTreeAll',
                // 请求头
                //  headers: { 'Authorization': 'Bearer ' + localStorage.getItem("X-TOKEN") },
                // 异步加载方式：get/post，默认get
                type: 'get',
                // 占位符
                placeholder: '大黄鱼',
                // 是否开启搜索功能：true/false，默认false
                search: true,
                // 一些可定制的样式
                style: {
                    folder: {
                        enable: true
                    },
                    line: {
                        enable: true
                    }
                },
                // 点击回调
                click: function (d) {
                    console.log(d);
                },
                // 加载完成后的回调函数
                success: function (d) {
                    console.log(d);
                    //                选中节点，根据id筛选
                    treeSelect.checkNode('varFishName', 3);

                    // console.log($('#varProjectName').val());

                    //                获取zTree对象，可以调用zTree方法
                    var treeObj = treeSelect.zTree('varFishName');
                    console.log(treeObj);

                    //                刷新树结构
                    treeSelect.refresh('varFishName');
                }
            });


            $(function () {
                myEcharts();
            })



            //var $b = layui.$;
            //active = {
            //    reload: function (page) {
            //        //执行重载
            //        table.reload('myTable', {
            //            page: {
            //                curr: page || 1 //重新从第 1 页开始
            //            },
            //            where: {
            //                sasearch: $("#keyword").val(),
            //                dateTime: $("#varRecordTime").val()
            //            }

            //        });
            //    }
            //};
            //$b('#search').on('click', function () {
            //    var type = $b(this).data('type');
            //    active[type] ? active[type].call(this) : '';
            //});
        })


        function myEcharts() {

            var parameter = {
                dateYears: $("#vardateTime").val(),
                fishName: $("#varFishName").val(),
                areName: $("#varProjectName").val()
            };
            console.log(parameter);
            var myChart = echarts.init(document.getElementById("main"));
            var time = "";
            var timetype = "";
            $.get("/MarketPrice/MarketFishYearsAll", parameter, function (result) {
                //console.log("123")
                //console.log(result.result.data)
                if (result.Code == "200") {
                    myChart.hideLoading();
                    // myChart.setOption(result.result);
                    result.data = JSON.stringify(result.result.data);
                    var dataX = [];
                    var dataY = [];

                    var thead = "<tr>";
                    var tbody = "<tr>";
                    for (var j = 0; j < result.result.data.length; j++) {
                        dataX.push(result.result.data[j].day);
                        dataY.push(result.result.data[j].price);

                        var fishName = result.result.data[j].fishName;

                        thead += "<td>" + result.result.data[j].day + "</td>";
                        tbody += "<td><a onclick='oenpage(\"" + result.result.data[j].day + "\")'>" + result.result.data[j].price + "</a></td>";
                    }
                    thead += "</tr>";
                    tbody += "/<tr>";
                    option = {
                        title: {
                            text: fishName + '价格分析',
                            x: 'center',
                            y: 20,
                        },
                        //   color: ['#47F4F6', '#FF4DA4', '#A67EFF', '#FFCD57', '#63E3BB', '#D955FF', '#3D98E5', '#FF8CBF', '#1FCFFF', '#FF9149', '#6CFF9B', '#FFE59F', '#2BECFF', '#D17AFF', '#5489FF', '#7EA5FF', '#72FFE1', '#FF7F87', '#34B3FF', '#FF8F7F'],
                        legend: {
                            textStyle: {
                                fontSize: 16
                            },
                            //x: 'center',
                            //y: -10,
                            //  data: legenddata
                        },
                        tooltip: {
                            trigger: 'axis',
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            }
                        },
                        toolbox: {
                            x: '85%',
                            y: 20,
                            feature: {
                                magicType: {
                                    show: true,
                                    type: ['line', 'bar'],
                                    title: { line: '折线图切换', bar: '柱形图切换' },
                                    iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                },
                                saveAsImage: {
                                    show: true, title: '下载', iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                }
                            },
                            textStyle: {//图例文字的样式
                            }
                        },
                        xAxis: {
                            name: '鱼种',
                            axisLabel: {
                                rotate: 60,
                                interval: 0

                            },
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            },

                            data: dataX
                        },
                        yAxis: {
                            type: 'value',
                            name: '',
                            margin: 10,
                            textStyle: {
                            },
                            axisLabel: {
                                interval: 'auto',
                                rotate: -15,
                                margin: 18,
                                formatter: '{value}/元'
                            },
                            axisLine: {    // 轴线
                                show: true,
                                lineStyle: {
                                    type: 'dashed',
                                    width: 1
                                }
                            }
                        },
                        series: [
                            {
                                data: dataY,
                                type: 'bar'
                            }
                        ]
                    };
                    myChart.clear();
                    myChart.setOption(option);
                    $("#thdata").html(thead);
                    $("#tbdata").html(tbody);
                } else {
                    alert(result.msg);
                }
            });
        }
    </script>
}

<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">关键字：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="keyword" name="keyword" style="width:240px" placeholder="">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">地区：</label>
        <div class="layui-input-inline">
            <input type="text" id="varProjectName" lay-filter="tree" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">鱼种：</label>
        <div class="layui-input-inline">
            <input type="text" id="varFishName" lay-filter="tree" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">年份：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="vardateTime" name="vardateTime" style="width:240px" placeholder="yyyy-MM-dd">
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-form-label">
            <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" onclick="myEcharts()" data-type="reload">搜索</button>
        </div>
    </div>
</blockquote>
<br />
<div id="main" style="height: 450px; width: 100%; min-width:300px"></div>
<br />


<table class="layui-table" id="dataview" lay-filter="datalist">
    <thead id="thdata"> </thead>
    <tbody id="tbdata"></tbody>
</table>
@*<table class="layui-hide" id="unshow" lay-filter="datalist"> </table>*@



